import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { Language } from "../../../../../extend/language/Language";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { PageButtonSelecter } from "../../common/pageSelect/PageButtonSelecter";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { FlyFootBmp } from "../../mapUI/flyFoot/FlyFootBmp";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { EffectManager } from "../../../manager/EffectManager";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { Cache } from "../../../cache/Cache";
import { ENpcEffect } from "../../../../../Message/Public/ENpcEffect";
import { AIManager } from "../../../scene/ai/AIManager";
import { AIType } from "../../../scene/ai/AIType";
import { PageSelecter } from "../../common/pageSelect/PageSelecter";
type int = number;
//class PetMingGuideWindow
    
    export  class PetMingGuideWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(665, 480);
            title = Language.getString(30149);
            titleHeight = 30;
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc2=null;
            super.createChildren();
            this._bg = new Object /* flash.display.Bitmap */();
            this._bg.x = 17;
            this._bg.y = 43;
            addChild(this._bg);
            LoaderHelp.addResCallBack(ResFileConst.PetMingGuide, this.onResLoaded);
            this._pageSelecter = new PageButtonSelecter();
            this._pageSelecter.move(270, 447);
            addChild(this._pageSelecter);
            this._pageSelecter.currentPage = 1;
            this._pageSelecter.maxPage = 5;
            this._pageSelecter.addEventListener(flash.events.Event.CHANGE, this.onPageChangeHandler);
            this._sprite = new Object /* flash.display.Sprite */();
            this._sprite.x = 450;
            this._sprite.y = 447;
            addChild(this._sprite);
            this._sprite.mouseEnabled = false;
            var loc1=ObjCreate.createTextField("", 0, 0, 150, 20, this._sprite, GlobalStyle.textFormat5);
            loc1.htmlText = "<a href=\'event: 0\'><u>" + Language.getString(35847) + "</u></a>";
            loc1.addEventListener(flash.events.TextEvent.LINK, this.onTextLickHandler);
            loc2 = new FlyFootBmp();
            loc2.x = loc1.x + loc1.textWidth;
            loc2.y = loc1.y;
            this._sprite.addChild(loc2);
            loc2.addEventListener(flash.events.MouseEvent.CLICK, this.onFlyFootClickHandler);
            return;
        }

        /* internal  */onResLoaded(): void
        {
            this._resLoadEnd = true;
            this._bg.bitmapData = GlobalClass.getBitmapData("page_" + this._index);
            return;
        }

        /* internal  */onPageChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            if (!this._resLoadEnd) 
            {
                return;
            }
            this._index = this._pageSelecter.currentPage;
            this._bg.bitmapData = GlobalClass.getBitmapData("page_" + this._index);
            if (this._index == 5) 
            {
                EffectManager.glowFilterReg(this._sprite, [FilterConst.guideTipsFilter], 0.6, 10, 5, 20);
            }
            return;
        }

        /* internal  */onFlyFootClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.gotoFly();
            return;
        }

        /* internal  */onTextLickHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            var loc1=Cache.instance.scene.getNpcByEffect(ENpcEffect._ENpcEffectPetStorage);
            AIManager.onAutoPathAIControl(loc1);
            return;
        }

        /* internal  */gotoFly(): void
        {
            var loc1=Cache.instance.scene.getNpcByEffect(ENpcEffect._ENpcEffectPetStorage);
            AIManager.onAIControl(loc1, AIType.AI_Convey);
            return;
        }

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_index: int=1;

        /* internal */ /* var */_pageSelecter: PageSelecter;

        /* internal */ /* var */_resLoadEnd: Boolean=false;

        /* internal */ /* var */_sprite: Object /* flash.display.Sprite */;

        public /* var */guideEndFuc: Function;
    }
